<?php
/**
 * Created by PhpStorm.
 * User: lee
 * Date: 2017/12/24
 * Time: 下午6:53
 */

namespace Biz\module\Classes\core;

abstract class StatusAbstract
{
    public static function getAdminActionList($status)
    {
        $data = [];
        if (isset(static::$statusAdminActionsMap[$status])) {
            foreach (static::$statusAdminActionsMap[$status] as $action) {
                $data[$action] = [
                    'name' => static::$actionsDesc[$action],
                    'url' => static::$actionsAdminUrl[$action],
                ];
            }
        }

        return $data;
    }

    public static function checkAdminAction($status, $action)
    {
        $actionList = self::getAdminActionList($status);

        if (!key_exists($action, $actionList)) {
            throw new \Exception('当前记录不可操作');
        }
    }
}